<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label required">角色名称</label>
                <div class="layui-input-block">
                    <input type="text" name="roleName" lay-verify="required" lay-reqtext="角色名称不能为空" placeholder="请输入角色名称" value="" class="layui-input">
                    <tip>填写角色名称</tip>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">角色编号</label>
                <div class="layui-input-block">
                    <input type="text" name="roleCode" lay-verify="required" lay-reqtext="角色编号不能为空" placeholder="请输入角色编号" value="" class="layui-input">
                    <tip>填写角色编号</tip>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">数据范围</label>
                <div class="layui-input-block">
                    <input type="radio" name="dataScope" value="1" title="全部" checked="">
                    <input type="radio" name="dataScope" value="0" title="单位">
                    <input type="radio" name="dataScope" value="0" title="部门">
                    <input type="radio" name="dataScope" value="0" title="个人">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="roleStatus" value="1" title="有效" checked="">
                    <input type="radio" name="roleStatus" value="0" title="无效">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">排序序号</label>
                <div class="layui-input-block">
                    <input type="number" name="orderNo" lay-verify="required" lay-reqtext="排序序号不能为空" placeholder="请输入排序序号" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">角色描述</label>
                <div class="layui-input-block">
                    <textarea name="roleDesc" class="layui-textarea" placeholder="请输入角色描述"></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <a class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">
                <i class="layui-icon layui-icon-ok"></i>保存
            </a>
            <a class="layui-btn layui-btn-normal" onclick="closeWindow()">
                <i class="layui-icon layui-icon-close"></i>取消
            </a>
        </div>
    </div>
</div>
<script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/lay-config.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (formdata) {
            formdata = formdata.field;

            $.ajax({
                type: 'POST',
                url: 'admin/rbac/role',
                data: JSON.stringify(formdata),
                contentType: 'application/json',
                success:function(result){
                    layer.alert(result.msg, function(){
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                        parent.layui.table.reload('RoleTableId');
                    });
                }
            });
        });
    });

    function closeWindow(){
        var iframeIndex = parent.layer.getFrameIndex(window.name);
        parent.layer.close(iframeIndex);
    }
</script>
</body>
</html>